package io.github.wslxm.springbootplus2.starter.websocket.topic;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.ChannelTopic;

/**
 * 发布者配置
 *
 * @author wangsong
 * @date 2023/05/17
 */
@Configuration
public class PubConfig {

    /**
     * 当前项目模块名称, 作用于 redis 前缀
     */
    @Value("${spring.application.name:no}")
    protected String moduleName;

    /**
     * 订阅发布的主题
     *
     * @return
     */
    @Bean
    public ChannelTopic topic() {
        return new ChannelTopic("pubsub:" + moduleName + "_queue-websocket");
    }
}
